package com.ls.controller.banner;

import com.ls.controller.banner.model.AddBannerModel;
import com.ls.controller.banner.model.EditBannerModel;
import com.ls.controller.banner.model.SortBannerModel;
import com.ls.controller.product.model.AddProductModel;
import com.ls.service.IBannerService;
import com.ls.service.ISysUserService;
import com.ls.utils.ResultData;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@Api(value = "banner相关PC接口", tags = "banner相关PC接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/banner")
public class BannerController {
    private final IBannerService service;
    /** app轮播图列表 */
    @GetMapping("getBanner")
    public ResultData getBanner() {
        return service.getBanner();
    }
    /** 新增轮播图 */
    @PostMapping("add")
    public ResultData add(@Valid @RequestBody AddBannerModel model) {
        return service.add(model);
    }
    /** 编辑轮播图 */
    @PostMapping("edit")
    public ResultData edit(@Valid @RequestBody EditBannerModel model) {
        return service.edit(model);
    }
    /**排序*/
    @PostMapping("sort")
    public ResultData sort(@Valid @RequestBody SortBannerModel model) {
        return service.sort(model);
    }
    /** 删除轮播图  */
    @PostMapping("del")
    public ResultData del(@RequestParam @NotNull(message = "id不得为空") Integer bannerId) {
        return service.del(bannerId);
    }
}
